<template>
  <div class="apply-detail">
    <swiper :imgList="imgList"></swiper>
    <div class="content">
      <div class="wrap">
        <!-- 比赛时间 -->
        <div class="apply-time">
          <div class="left">
            <p class="time-btn">比赛时间</p>
          </div>
          <div class="right">
            <p class="text">{{applyTime}}</p>
          </div>
        </div>
        <!-- 比赛地点 -->
        <div class="apply-address">
          <div class="left">
            <p class="address-btn">比赛地址</p>
          </div>
          <div class="right">
            <p class="text">{{applyAddress}}</p>
          </div>
        </div>
        <!-- 主办单位 -->
        <div class="apply-units">
          <div class="left">
            <p class="units-btn ">主办单位</p>
          </div>
          <div class="right">
            <p class="text">{{applyUnits}}</p>
          </div>
        </div>
        <!-- 竞赛要求 -->
        <div class="apply-rule">
          <div class="left">
            <p class="rule-btn">竞赛要求</p>
          </div>
          <div class="right">
            <p class="text">{{sportway}}</p>
          </div>
        </div>
        <!-- 奖项设置 -->
        <div class="apply-prize">
          <div class="left">
            <p class="prize-btn">奖项设置</p>
          </div>
          <div class="right">
            <p class="text">{{awartsetting}}</p>
          </div>
        </div>
      </div>
      <div class="bottom-btn">
        <div class="fixed" @click="sign( applyId, applyTitle)" v-if="isApply=== 0">
          <p>参加报名</p>
        </div>
        <div class="fixed success" v-if="isApply=== 1">
          <p>已报名</p>
        </div>
        <div class="fixed over" v-if="isApply===-1">
          <p>已过期</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {config, _isPhoneNumber} from '@/util/config'
  import Swiper from '@/components/swiper/Swiper'
  import axios from 'axios'

  export default {
    name: "findDetail",
    data() {
      return {
        isApply: 0,
        applyId: 0,
        applyTitle: '',
        imgList: [],
        prize: 0,
        applyTime: '',
        applyAddress: '',
        applyUnits: '',
        sportway: '',
        awartsetting: '',
      }
    },
    components: {Swiper},
    mounted() {
      this.getAllInfo('/api/sportslist/read');
    },
    methods: {
      sign() {this.$router.push({name: 'detailSign ', params: {id: this.applyId, imgList: this.imgList, prize: this.prize}})},
      // 数据请求
      getAllInfo(url) {
        let id = this.$route. params.id;
        axios.post(url, {
          'id': id,
          'memberid': config.memberid,
        }).then((res) => {
          res = res.data.data
          let ImgArr = []
          ImgArr.push({
            bannerpic: res.pic
          })
          this.applyTitle = res.title;
          this.applyId = res.id;
          this.prize = res.sportfee;
          this.imgList = ImgArr;
          this.applyTime = res.sporttime;
          this.applyAddress = res.sportarea;
          this.applyUnits = res.sportcomp;
          this.sportway = res.sportway;
          this.awartsetting = res.awartsetting;
          this.isApply = res.hassub;
        })
      },
    },
  }
</script>

<style scoped lang="less">
  .content {
    .wrap {
      .apply-time, .apply-address, .apply-units, .apply-rule, .apply-prize {
        display: flex;
        margin: 12px;
        font-size: 14px;
        .left {
          width: 90px;
          .time-btn, .address-btn, .units-btn, .rule-btn, .prize-btn {
            padding: 4px;
            background: #1bbacd;
            border-radius: 4px;
            text-align: center;
            color: #fff;
          }
          .address-btn {
            background: #ffac66;
          }

          .units-btn {
            background: #ff6565;
          }

          .rule-btn {
            background: #a6d640;
          }

          .prize-btn {
            background: #708bce;
          }
        }
        .right {
          text-align: left;
          flex: 1;
          padding-top: 3px;
          margin-left: 12px;
          .text {
            line-height: 150%;
            color: #666;
          }
        }
      }
    }
    .bottom-btn {
      .fixed {
        width: 100%;
        height: 42px;
        line-height: 42px;
        text-align: center;
        color: #fff;
        font-size: 14px;
        bottom: 0;
        left: 0;
        position: fixed;
        background: #708bce;

      }
      .success {
        background: #ff6565;
      }
      .over {
        background: #9f9f9f;
      }
    }
  }
</style>
